<?php
include("VerifySession.php");
?>
<?php
 	include("Header.php");
	include("SNManager.class.php");
	$db = new SNDataManager();
?>

<?php
    $result =false;
    $varCode = $_REQUEST['txtUserCode'];
    $varLevel = $_REQUEST['txtLevel'];
    $varFirstName = $_REQUEST['txtFirstName'];
    $varLastName = $_REQUEST['txtLastName'];
    $varLoginName = $_REQUEST['txtLoginName'];
    $varUserID= $_REQUEST['hdUserID'];
    $varPasswords = $_REQUEST['txtPasswords'];
    $varRePasswords = $_REQUEST['txtRePasswords'];
    if($varUserID == null) $varUserID= 0;
    if($db->CheckDupicateUserInfo($varUserID ,$varLoginName,$varCode))
    {
        $msg= "Login Name '".$varLoginName."' already used.";
        echo "<script type='text/javascript'>alert('".$msg."');</script>";        
        //header( 'Location:AccountPage.php' );
    }else
    {
        $result= $db->SaveUserInfo($varUserID, $varLoginName, $varPasswords, $varCode, $varLevel,$varFirstName,$varLastName);
        if($result) $msg= "Save Account Success.";
        else $msg= "Save Account Failed.";
        
        echo "<script type='text/javascript'>alert('".$msg."');</script>";
        //header( 'Location:AccountPage.php' );
    }
    $db->redirect("AccountPage.php");
?>

 <?php
   include("Footer.php");
?>